package com.itheima.mapper;

import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckItemMapper {
    /**
     * 查询所有检查项
     * @return
     */
@Select("select * from t_checkitem")
    List<CheckItem> findAll();
    /**
     * 通过id查询检查项
     * @param id
     * @return
     */
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);
    /**
     * 根据检查组id查询关联的检查项id
     * @param id
     * @return
     */
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer id);
    /**
     * 根据id删除检查项
     * @param id
     * @return
     */
    @Delete("delete from t_checkitem where id = #{id}")
    Boolean delete(Integer id);
//    @Delete("delete from t_checkgroup_checkitem where checkitem_id = #{id}")
//    Boolean deleteGroup(Integer id);
    /**
     * 新增
     * @param checkItem
     * @return
     */
    @Insert("insert into t_checkitem(code, name, sex, age, price, type, attention, remark) value (#{code},#{name},#{sex},#{age},#{price},#{type},#{attention},#{remark}) ")
    boolean add(CheckItem checkItem);
    /**
     * 编辑
     * @param checkItem
     * @return
     */
    boolean edit(CheckItem checkItem);
}
